package com.ruoyi.SSL.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.SSL.domain.SslNotificationLog;
import com.ruoyi.SSL.service.ISslNotificationLogService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 消息提醒记录Controller
 *
 * @author ruoyi
 * @date 2024-11-22
 */
@Controller
@RequestMapping("/SSL/notificationLog")
public class SslNotificationLogController extends BaseController
{
    private String prefix = "SSL/notificationLog";

    @Autowired
    private ISslNotificationLogService sslWarmLogService;

    @RequiresPermissions("SSL:notificationLog:view")
    @GetMapping()
    public String notificationLog()
    {
        return prefix + "/notificationLog";
    }

    /**
     * 查询消息提醒记录列表
     */
    @RequiresPermissions("SSL:notificationLog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SslNotificationLog sslWarmLog)
    {
        startPage();
        List<SslNotificationLog> list = sslWarmLogService.selectSslWarmLogList(sslWarmLog);
        return getDataTable(list);
    }

    /**
     * 导出消息提醒记录列表
     */
    @RequiresPermissions("SSL:notificationLog:export")
    @Log(title = "消息提醒记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SslNotificationLog sslWarmLog)
    {
        List<SslNotificationLog> list = sslWarmLogService.selectSslWarmLogList(sslWarmLog);
        ExcelUtil<SslNotificationLog> util = new ExcelUtil<SslNotificationLog>(SslNotificationLog.class);
        return util.exportExcel(list, "消息提醒记录数据");
    }

    /**
     * 新增消息提醒记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存消息提醒记录
     */
    @RequiresPermissions("SSL:notificationLog:add")
    @Log(title = "消息提醒记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SslNotificationLog sslWarmLog)
    {
        return toAjax(sslWarmLogService.insertSslWarmLog(sslWarmLog));
    }

    /**
     * 修改消息提醒记录
     */
    @RequiresPermissions("SSL:notificationLog:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SslNotificationLog sslWarmLog = sslWarmLogService.selectSslWarmLogById(id);
        mmap.put("sslWarmLog", sslWarmLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存消息提醒记录
     */
    @RequiresPermissions("SSL:notificationLog:edit")
    @Log(title = "消息提醒记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SslNotificationLog sslWarmLog)
    {
        return toAjax(sslWarmLogService.updateSslWarmLog(sslWarmLog));
    }

    /**
     * 删除消息提醒记录
     */
    @RequiresPermissions("SSL:notificationLog:remove")
    @Log(title = "消息提醒记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sslWarmLogService.deleteSslWarmLogByIds(ids));
    }
}
